81 buildings
Downloading Microsoft and Google Building Footprints
This notebook demonstrates how to download Microsoft and Google Building Footprints and merge them into a single vector file.
- Microsoft Global Building Footprints: https://github.com/microsoft/GlobalMLBuildingFootprints
- Google Open Buildings: https://sites.research.google/open-buildings
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install -U leafmap geopandas
# %pip install -U leafmap geopandas
In [2]:
Copied!
import leafmap
import leafmap
Specify the country name.
In [3]:
Copied!
country = "Libya"
country = "Libya"
Specify the number of files to download. Set to None to download all files.
In [4]:
Copied!
head = 2
head = 2
Download the Microsoft building footprints.
In [5]:
Copied!
leafmap.download_ms_buildings(
country,
out_dir="buildings",
merge_output=f"{country}_ms.shp",
head=head
)
leafmap.download_ms_buildings(
country,
out_dir="buildings",
merge_output=f"{country}_ms.shp",
head=head
)
Found 84 links for Libya Downloading 1 of 2: 122003333.geojson Downloading 2 of 2: 122012202.geojson Reading 1 of 2: buildings/122003333.geojson Reading 2 of 2: buildings/122012202.geojson Merging GeoDataFrames ... Saving merged file to Libya_ms.shp ... Saved merged file to Libya_ms.shp
Out[5]:
['buildings/122003333.geojson', 'buildings/122012202.geojson']
Display the Microsoft building footprints.
In [6]:
Copied!
m = leafmap.Map()
m.add_basemap("SATELLITE")
m.add_vector(f"{country}_ms.shp", layer_name="MS Buildings")
m
m = leafmap.Map()
m.add_basemap("SATELLITE")
m.add_vector(f"{country}_ms.shp", layer_name="MS Buildings")
m
Out[6]:
Download the Google building footprints.
In [7]:
Copied!
leafmap.download_google_buildings(
country,
out_dir="buildings",
merge_output=f"{country}_google.shp",
head=head,
overwrite=True
)
leafmap.download_google_buildings(
country,
out_dir="buildings",
merge_output=f"{country}_google.shp",
head=head,
overwrite=True
)
Found 7 links for Libya.
Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/13d_buildings.csv.gz To: /home/runner/work/leafmap/leafmap/docs/notebooks/buildings/13d_buildings.csv.gz 100%|██████████| 306k/306k [00:00<00:00, 960kB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/141_buildings.csv.gz To: /home/runner/work/leafmap/leafmap/docs/notebooks/buildings/141_buildings.csv.gz 100%|██████████| 1.01M/1.01M [00:00<00:00, 2.16MB/s]
Merging GeoDataFrames ...
Display the Google building footprints.
In [8]:
Copied!
url = 'https://sites.research.google/open-buildings/tiles.geojson'
url = 'https://sites.research.google/open-buildings/tiles.geojson'
In [9]:
Copied!
m = leafmap.Map()
m.add_basemap("SATELLITE")
m.add_geojson(url, layer_name="Google Building Coverage")
m.add_vector(f"{country}_google.shp", layer_name="Google Buildings")
m
m = leafmap.Map()
m.add_basemap("SATELLITE")
m.add_geojson(url, layer_name="Google Building Coverage")
m.add_vector(f"{country}_google.shp", layer_name="Google Buildings")
m
Out[9]:
Last update:
2023-11-27
Created: 2023-11-27
Created: 2023-11-27